import React from "react";
import { Select } from "antd";
import { useTranslation } from "react-i18next";

function Index() {
  const {t, i18n} = useTranslation();
  const yu = localStorage.getItem("yu") || i18n.language || "zh";
  const handleChange = (value: string) => {
    i18n.changeLanguage(value);
    localStorage.setItem("yu", value);
  };
  return (
    <div>
      <Select
        defaultValue={yu}
        style={{ width: 120 }}
        onChange={handleChange}
        options={[
          { value: "en", label: "英文模式" },
          { value: "zh", label: "中文模式" },
        ]}
      />
      <h1>{t("Welcome to React")}</h1>
    </div>
  );
}

export default Index;
